package io.codegeneratetool.util.validate;

import java.lang.reflect.Field;
import java.util.Map;

import javax.validation.constraints.Pattern;

/**
 * 说明：
 * 
 *  对正则表达式的注解解析
 */
public class PatternProcessor extends BaseProcessorChain<Pattern> {

	public <T> void process(T t, Field field,
			Map<String, Object> validateContainer, Map<String, Object> messages) {
		Pattern annotation = field.getAnnotation(Pattern.class);
		String pattern = annotation.regexp();
		validateContainer.put("kjPattern", pattern.replace("\\", "\\\\") );
		messages.put("kjPattern", getMessage(annotation.message(),"格式匹配错误: "+ pattern));


	}

}
